using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace QLNS.Data
{
    public class ThongTinNhanVien_db
    {
        Services m_Ds = new Services();
        public ThongTinNhanVien_db() { }

        public DataTable DanhSachThongTinNhanVien()
        {
            
            OleDbCommand cmd = new OleDbCommand("SELECT TTNV.ID AS ID, TTNV.Ten,TTNV.NgaySinh,TTNV.GioiTinh,TTNV.QuocTich, TTNV.DanToc,TTNV.TonGiao,TTNV.SoCMND,TTNV.NgayCap,TTNV.NoiCap,TTNV.DiaChiThuongTru,TTNV.DiaChiTamTru,TTNV.SoDienThoai,TTNV.TrinhDo,TTNV.NgayVaoLam,TTNV.NgoaiNgu,TTNV.TinHoc,TTNV.ChinhTri FROM THONGTINNHANVIEN TTNV, NHANVIEN NV, QUOCTICH QT, DANTOC DT, TONGIAO TG,TRINHDO TD, NGOAINGU NN,TINHOC TH, CHINHTRI CT WHERE TTNV.ID=NV.ID and TTNV.QuocTich=QT.ID and TTNV.DanToc=DT.ID and TTNV.TonGiao=TG.ID and TTNV.TrinhDo=TD.ID and TTNV.NgoaiNgu=NN.ID and TTNV.TinHoc=TH.ID and TTNV.ChinhTri=CT.ID"); 
            
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataRow NewRow()
        {
            return m_Ds.NewRow();
        }

        public void Add(DataRow row)
        {
            m_Ds.Rows.Add(row);
        }

        public bool Save()
        {
            return m_Ds.ExecuteNoneQuery() > 0;
        }
        public DataTable TimTheoTen(string ten)
        {
            string sql = "SELECT * FROM THONGTINNHANVIEN where Ten like '%" + ten + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataTable TimTheoMa(string id)
        {
            string sql = "SELECT * FROM THONGTINNHANVIEN where ID like '%" + id + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }
    }
}
